#pragma once
#include "rviz_custom_plugins/panels/ui_command_panel.h"
#include <rviz_common/panel.hpp>
#include <rviz_common/config.hpp>
#include <controller_msgs/srv/control_cmd.hpp>
#include <rviz_common/display_context.hpp>
#include <rclcpp/rclcpp.hpp>
#include "rviz_custom_plugins/utils/widget_manager.h"


using rviz_custom_plugins::utils::WidgetManager;
using rviz_common::Config;
using controller_msgs::srv::ControlCmd;
using rviz_common::DisplayContext;


namespace rviz_custom_plugins {


namespace panels {


class CommandPanel : public rviz_common::Panel
{
    Q_OBJECT

public:
    explicit CommandPanel(QWidget *parent = nullptr);

    void load(const Config& config) override;

    void onInitialize() override;

private:
    Ui::commandPanel* ui{ nullptr };

    rclcpp::Node::SharedPtr node;
    rclcpp::Client<ControlCmd>::SharedPtr oprCmdClient;

    QPointer<WidgetManager> widgetManager;

    void sendControlCmd(std::shared_ptr<ControlCmd::Request> request);

    void startBtnClicked();
    void stopBtnClicked();
    void pauseBtnClicked();
    void resumeBtnClicked();
    void switchBtnClicked();
    void activeBtnClicked();
    void inActiveBtnClicked();
    void returnBtnClicked();
    void landBtnClicked();
    void photoBtnClicked();
    void videoBtnClicked();


private slots:
    void handleWidgetShow(int widgetId, bool isShow);

};

}


}